package com.bayair.doctor.ui.inquiry_record;

import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.MultipleItemRvAdapter;
import com.tencent.qcloud.tim.uikit.modules.conversation.base.ConversationInfo;

import java.util.List;

import androidx.annotation.Nullable;

public class InquiryRecordAdapter extends MultipleItemRvAdapter<ConversationInfo, BaseViewHolder> {

    public InquiryRecordAdapter(@Nullable List<ConversationInfo> data) {
        super(data);

        //构造函数若有传其他参数可以在调用finishInitialize()之前进行赋值，赋值给全局变量
        //这样getViewType()和registerItemProvider()方法中可以获取到传过来的值
        //getViewType()中可能因为某些业务逻辑，需要将某个值传递过来进行判断，返回对应的viewType
        //registerItemProvider()中可以将值传递给ItemProvider
        finishInitialize();
    }

    @Override
    protected int getViewType(ConversationInfo entity) {
        //根据实体类判断并返回对应的viewType，具体判断逻辑因业务不同，这里这是简单通过判断type属性
        return entity.getType();//会话类型
    }

    @Override
    public void registerItemProvider() {
        //注册相关的条目provider
        //Register related entries provider
        mProviderDelegate.registerProvider(new CommonProvider());
        mProviderDelegate.registerProvider(new CustomProvider());
    }

}
